package com.leoman.message.handers;

import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.cp.api.WxCpMessageHandler;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;

import java.util.Map;

/**
 * 文本消息处理器
 * Created by wangbin on 2015/6/24.
 */
public class TextMessageHandler implements WxCpMessageHandler {

    @Override
    public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, WxCpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
        String content = wxMessage.getContent();
        return WxCpXmlOutMessage.TEXT().content("你说:" + content).fromUser(wxMessage.getToUserName()).toUser(wxMessage.getFromUserName()).build();
    }

}